package com.example.demo.mapper;

import com.example.demo.entity.Sort;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface SortMapper {

    @Select("select * from sort")
    List<Sort> findAll();
    @Update("insert into sort(`name`)values(#{name})")
    @Transactional
     void add(Sort Sort);
    @Update("UPDATE sort SET name = #{name} WHERE id = #{id}")
    void update(Sort Sort);
    @Delete("DELETE FROM sort WHERE id = #{id}")
    void deleteById(Sort Sort);
//     // 查询是否有当前书名方法
    @Select("SELECT * FROM sort WHERE name = #{name}")
    Sort findBySortname(String name);
}
